package com.example.ercmssystem2.service.impl;

import com.example.ercmssystem2.entity.EventType;
import com.example.ercmssystem2.repository.EventTypeRepository;
import com.example.ercmssystem2.service.EventTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class EventTypeServiceImpl implements EventTypeService {

    @Autowired
    private EventTypeRepository eventTypeRepository;

    @Override
    public EventType findById(Long id) {
        return eventTypeRepository.findById(id).orElse(null);
    }

    @Override
    public List<EventType> findAllEventTypes() {
        return eventTypeRepository.findAll();
    }

    @Override
    public EventType saveEventType(EventType eventType) {
        return eventTypeRepository.save(eventType);
    }

    @Override
    public void deleteEventType(Long id) {
        eventTypeRepository.deleteById(id);
    }

    @Override
    public List<EventType> findByEnabledTrue() {
        return eventTypeRepository.findByEnabledTrue();
    }

    @Override
    public EventType findByName(String name) {
        return eventTypeRepository.findByName(name);
    }
} 